package com.bird;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @data 2023/2/19 16:48
 * @author: bird
 * @description:
 */

@Configuration
@ComponentScan(basePackages = {"com.bird"})
public class Entrance {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext=new AnnotationConfigApplicationContext(Entrance.class);
        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println("bean的名字: "+ beanDefinitionName);
        }
        // 查看修改的后的属性
        BeanDefinition teacher = applicationContext.getBeanDefinition("teacher");
        String scope = teacher.getScope();
        String beanClassName = teacher.getBeanClassName();
        System.out.println(beanClassName+" : "+scope );

        // 查看postProcessor
        Object bean = applicationContext.getBean("student-22");
        System.out.println(bean);

    }
}
